<?php

namespace app\common\model\product;

use think\facade\Cache;
use app\common\model\BaseModel;

/**
 * 字典类型模型
 */
class RechargeDictType extends BaseModel
{
    protected $pk = 'dict_id';
    protected $name = 'recharge_dict_type';

    public function rechargeTempDictType()
    {
        return $this->hasMany('app\\common\\model\\product\\RechargeTempDictType', "dict_id","dict_id");
    }

    /**
     * 详情
     */
    public static function detail($category_id)
    {
        return (new static())->find($category_id);
    }

    /**
     * 获取列表
     */
    public function getList($param)
    {
        // 商品列表获取条件
        $params = array_merge([
        ], $param);

        // 筛选条件
        $filter = [];
        $model = $this;
        if (!empty($params['dict_name'])) {
            $model = $model->where('dict_name', 'like', '%' . trim($params['dict_name']) . '%');
        }

        $list = $model
            ->field(['*'])
            ->where($filter)
            ->order("dict_id desc")
            ->paginate($params);

        // 整理列表数据并返回
        return $list;
    }

}
